package com.GlobalPaint.app.ui.Mine.Laborer;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.GlobalPaint.app.R;
import com.GlobalPaint.app.utils.MyViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.finalteam.toolsfinal.adapter.FragmentAdapter;

public class MyJobWantedActivity extends AppCompatActivity {
    @BindView(R.id.iv_goback)
    ImageView ivGoback;
    @BindView(R.id.tv_common_center)
    TextView tvCommonCenter;
    @BindView(R.id.tv_job_wanted)
    TextView tvJobWanted;
    @BindView(R.id.vw_job_wanted)
    View vwJobWanted;
    @BindView(R.id.ll_job_wanted)
    LinearLayout llJobWanted;
    @BindView(R.id.tv_recruit)
    TextView tvRecruit;
    @BindView(R.id.vw_recruit)
    View vwRecruit;
    @BindView(R.id.ll_recruit)
    LinearLayout llRecruit;
    @BindView(R.id.view_pager)
    MyViewPager viewPager;
    @BindView(R.id.tv_linshi)
    TextView tvLinshi;
    @BindView(R.id.vw_linshi)
    View vwLinshi;
    @BindView(R.id.ll_linshi)
    LinearLayout llLinshi;
    private MyJobWantedFragment jobWantedFragment;
    private MyRecruitFragment recruitFragment;
    private MYLinshiFragment myLinshiFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_job_wanted);
        ButterKnife.bind(this);
        tvCommonCenter.setText("我的用工");
        //初始化TabLayout的title数据集
        List<String> titles = new ArrayList<>();
        titles.add("");
        titles.add("");
        titles.add("");
        jobWantedFragment = new MyJobWantedFragment();
        recruitFragment = new MyRecruitFragment();
        myLinshiFragment = new MYLinshiFragment();
        //初始化ViewPager的数据集
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(jobWantedFragment);
        fragments.add(recruitFragment);
        fragments.add(myLinshiFragment);
        //创建ViewPager的adapter
        FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager(), fragments, titles);
        viewPager.setAdapter(adapter);
        viewPager.setOffscreenPageLimit(3);
    }

    @OnClick({R.id.iv_goback, R.id.ll_job_wanted, R.id.ll_recruit,R.id.ll_linshi})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_goback:
                finish();
                break;
            case R.id.ll_job_wanted:
                tvJobWanted.setTextColor(Color.rgb(37, 168, 37));
                tvRecruit.setTextColor(Color.rgb(144, 144, 144));
                tvLinshi.setTextColor(Color.rgb(144, 144, 144));
                vwJobWanted.setVisibility(View.VISIBLE);
                vwRecruit.setVisibility(View.GONE);
                vwLinshi.setVisibility(View.GONE);
                viewPager.setCurrentItem(0);
                break;
            case R.id.ll_recruit:
                tvJobWanted.setTextColor(Color.rgb(144, 144, 144));
                tvLinshi.setTextColor(Color.rgb(144, 144, 144));
                tvRecruit.setTextColor(Color.rgb(37, 168, 37));
                vwLinshi.setVisibility(View.GONE);
                vwJobWanted.setVisibility(View.GONE);
                vwRecruit.setVisibility(View.VISIBLE);
                viewPager.setCurrentItem(1);
                break;
            case R.id.ll_linshi:
                tvLinshi.setTextColor(Color.rgb(37, 168, 37));
                tvJobWanted.setTextColor(Color.rgb(144, 144, 144));
                tvRecruit.setTextColor(Color.rgb(144, 144, 144));
                vwLinshi.setVisibility(View.VISIBLE);
                vwJobWanted.setVisibility(View.GONE);
                vwRecruit.setVisibility(View.GONE);
                viewPager.setCurrentItem(2);
                break;
        }
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
